GLib added one-shot variants of the idle/timeout functions a while ago.
While they don't save a lot of code, they serve as a clear marker that
the callback is only invoked once.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3947>
cache_state_free (state);
}
-static gboolean
+static void
shell_app_cache_do_update (gpointer user_data)
{
ShellAppCache *cache = user_data;
task = g_task_new (cache, cache->cancellable, apply_update_cb, NULL);
g_task_set_source_tag (task, shell_app_cache_do_update);
g_task_run_in_thread (task, shell_app_cache_worker);
-
- return G_SOURCE_REMOVE;
}
static void
if (self->queued_update != 0)
g_source_remove (self->queued_update);
- self->queued_update = g_timeout_add_seconds (DEFAULT_TIMEOUT_SECONDS,
- shell_app_cache_do_update,
- self);
+ self->queued_update = g_timeout_add_seconds_once (DEFAULT_TIMEOUT_SECONDS,
+ shell_app_cache_do_update,
+ self);
}
static void
static void on_focus_app_changed (ShellWindowTracker *tracker, GParamSpec *spec, ShellAppUsage *self);
static void ensure_queued_save (ShellAppUsage *self);
-static gboolean idle_save_application_usage (gpointer data);
+static void idle_save_application_usage (gpointer data);
static void restore_from_file (ShellAppUsage *self);
{
if (self->save_id != 0)
return;
- self->save_id = g_timeout_add_seconds (SAVE_APPS_TIMEOUT_SECONDS, idle_save_application_usage, self);
+ self->save_id = g_timeout_add_seconds_once (SAVE_APPS_TIMEOUT_SECONDS,
+ idle_save_application_usage, self);
g_source_set_name_by_id (self->save_id, "[gnome-shell] idle_save_application_usage");
}
}
/* Save app data lists to file */
-static gboolean
+static void
idle_save_application_usage (gpointer data)
{
ShellAppUsage *self = SHELL_APP_USAGE (data);
{
g_debug ("Could not save applications usage data: %s", error->message);
g_error_free (error);
- return FALSE;
+ return;
}
buffered_output = g_buffered_output_stream_new (G_OUTPUT_STREAM (output));
g_object_unref (output);
g_debug ("Could not save applications usage data: %s", error->message);
g_error_free (error);
}
- return FALSE;
}
static void
clutter_gesture_get_point_coords_abs (CLUTTER_GESTURE (self),
point,
&latest_coords);
-
+
graphene_point_distance (&latest_coords, &begin_coords, &distance_x, &distance_y);
switch (self->side)
return FALSE;
}
-static gboolean
+static void
on_cancel_timeout (gpointer data)
{
ShellEdgeDragGesture *self = data;
clutter_gesture_set_state (CLUTTER_GESTURE (self), CLUTTER_GESTURE_STATE_CANCELLED);
self->cancel_timeout_id = 0;
- return G_SOURCE_REMOVE;
}
static void
self->cancel_timeout_point = point;
g_assert (self->cancel_timeout_id == 0);
- self->cancel_timeout_id = g_timeout_add (CANCEL_TIMEOUT_MS, on_cancel_timeout, self);
+ self->cancel_timeout_id = g_timeout_add_once (CANCEL_TIMEOUT_MS, on_cancel_timeout, self);
}
static void
static void finish_wait_windows (PerfHelperApp *app);
static void check_finish_wait_windows (PerfHelperApp *app);
-static gboolean
+static void
on_timeout (gpointer data)
{
PerfHelperApp *app = data;
destroy_windows (app);
g_application_quit (G_APPLICATION (app));
-
- return FALSE;
}
static void
{
g_clear_handle_id (&app->timeout_id, g_source_remove);
- app->timeout_id = g_timeout_add (opt_idle_timeout * 1000, on_timeout, app);
+ app->timeout_id = g_timeout_add_once (opt_idle_timeout * 1000, on_timeout, app);
g_source_set_name_by_id (app->timeout_id, "[gnome-shell] on_timeout");
}
static void auth_request_complete (AuthRequest *request,
gboolean dismissed);
-static gboolean
+static void
handle_cancelled_in_idle (gpointer user_data)
{
AuthRequest *request = user_data;
{
auth_request_complete (request, FALSE);
}
-
- return FALSE;
}
static void
*
* https://bugzilla.gnome.org/show_bug.cgi?id=642968
*/
- id = g_idle_add (handle_cancelled_in_idle, request);
+ id = g_idle_add_once (handle_cancelled_in_idle, request);
g_source_set_name_by_id (id, "[gnome-shell] handle_cancelled_in_idle");
}